package com.tron.dobest.security;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 描述：
 *
 * @author TRON
 * @since 2020-03-13
 */
@Slf4j
@Component
public class TronLogoutHandler implements LogoutHandler {
    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        log.info("======用户下线处理======");
        Object principal = null;
        try {
            principal = authentication.getPrincipal();
        } catch (Exception e) {
            log.info("获取注销用户信息："+e.getMessage());
        }
        log.info("======下线用户信息：{}======", principal);
    }
}
